<div id="breadcrumb">
    <a onclick="javascript:history.go(-1);" class="go-to-home tip-bottom font font18" style="cursor: pointer;">
        <i class="icon-arrow-left"></i> 返回 &nbsp;
    </a> 
    <a onclick="javascript:history.go(-1);" class="font font18" style="cursor: pointer;"> &nbsp;&nbsp;<span>推广员 &gt</span></a>
    <a href="/anchor/anchorinfo?uid={{info['uid']}}" class="current font font18"> <span>账号详情</span></a>
    
</div>

{% include "pull/consumption.html" %}

<link rel="stylesheet" href="{{static_url('web/css/icon/style-icon.css')}}">
<link rel="stylesheet" href="{{static_url('web/css/ui.daterangepicker.css')}}">
<script src="{{static_url('web/js/daterangepicker.jQuery.js')}}"></script>
<script src="{{static_url('web/js/jquery.ui.datepicker-zh-CN.js')}}"></script>
<script type="text/javascript">

    $(function() {
        $('body').addClass('anchorinfo');

        $('#mydate').daterangepicker({
                    presetRanges:[
                        //{text:'最近一周', dateStart:'yesterday-7days', dateEnd:'yesterday' },
                        //{text:'最近一月', dateStart:'yesterday-1month', dateEnd:'yesterday' },
                        //{text:'最近一年', dateStart:'yesterday-1year', dateEnd:'yesterday' }
                    ],
                    presets:{
                        dateRange:'自定义时间'
                    },
                    rangeStartTitle:'起始日期',
                    rangeEndTitle:'结束日期',
                    nextLinkText:'下月',
                    prevLinkText:'上月',
                    doneButtonText:'确定',
                    cancelButtonText:'取消',
                    earliestDate:'',
                    latestDate:Date.parse('today'),
                    constrainDates:true,
                    rangeSplitter:'-',
                    dateFormat:'yy-mm-dd',
                    closeOnSelect:false,
                    onOpen:function(){
                        $('.ui-daterangepicker-dateRange').click().parent().hide();
                        $('.ui-daterangepickercontain').css({left:($('#mydate').offset().left-325)+'px'});
                        $('.ui-daterangepickercontain').css({top:($('#mydate').offset().top+25)+'px'});
                    },
                    onClose:function(){
                        getDataList();
                    }
                }
        );

        getDataList();
    });

    function getDataList(index){
        var data={};
        data.uid=$('#an_uid').val();

        if($('#mydate').val() != ''){
            var tempdate = $('#mydate').val().substring(0,10);
            data.startTime = tempdate;//datetime_to_unix(tempdate);
        }else{
            data.startTime = '';
        }

        if($('#mydate').val() != '' && $('#mydate').val().length>13){
            var tempdate = $('#mydate').val().substring(13,23);
            data.endTime = tempdate;//datetime_to_unix(tempdate);
        }else{
            data.endTime = '';
        }
        if(data.endTime == ''){
            data.endTime = data.startTime;
        }

        data.searchId = $('#searchId').val();
        data.page=index||1;
        data.pageSize=global.pageSize;
        $.ajax({
            type:"POST",
            data:data,
            url:'/ajax/consumerInfo',
            dataType:'json',
            success:function(res){
                var data=res.data;
                var tableList=document.getElementById("tableList");
                var tbody= tableList.getElementsByTagName('tbody')[0];
                dataTable.clearData(tbody);

                // var sum=document.getElementById('sum');
                // sum.innerHTML=data.sum;
                var total=document.getElementById('total');
                total.innerHTML=data.total;
                var count=document.getElementById('count');
                count.innerHTML=data.count;
                // alert(data.list.length);

                for(var i=0;i<data.list.length;i++){
                    addRow(tbody,data.list[i]);
                }
                if(!index||index==0){
                    utilsPagination("#pagination",data.count,global.pageSize,function(page_index,jq){
                        page_index+=1;
                        getDataList(page_index);
                    });
                }
            }

        });
    }

    function addRow(table,data){

        var row=table.insertRow();
        var cell=row.insertCell(0);
        var cell1=row.insertCell(1);
        var cell2=row.insertCell(2);
        var cell3=row.insertCell(3);
        var cell4=row.insertCell(4);


        /*var div=document.createElement("div"),
                img=document.createElement("img"),
                span=document.createElement("span");

        div.className="anchor-info";
        img.src=global.contract+data.avatar;
        span.innerHTML=data.uid;

        div.appendChild(img);
        div.appendChild(span);*/

        cell.innerHTML=data.createTime;
        cell1.innerHTML=data.amount;
        cell2.innerHTML=data.type==1?'VIP':data.type==2?'座驾':data.type==3?'守护':data.type==4?'抢座':data.type==5?'送礼物':data.type==6?'银喇叭':data.type==7?'金喇叭':'';
        cell3.innerHTML=data.count;

        cell4.innerHTML=data.nickName+'('+data.anchorId+')';
        return row;
    }


    //  添加号码
    function myDilog(id){

    $('#myDilog').dialog({
        autoOpen:true,
        width:400,
        height:250,
        title:'发放人民币',
        resizable:false,
        modal:true,
        open:function(){

        },
        buttons: {
            "确定": function () {
                var data={};
                data.uid=id;
                data.num=$('#grantNum').val();
                $.ajax({
                    type:"POST",
                    data:data,
                    url:'/ajax/grant',
                    dataType:'json',
                    success:function(res){
                        location.reload();
                    }

                });


            }//,
            /*"取消": function () {


            }*/
        }
    });
}
</script>